package cc.ycws.core.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 复制图片
 *
 * @author Administrator
 */
public class CopyImge {
    /**
     * 字节输出流
     */
    private static FileOutputStream fos = null;

    /**
     * 字节输入流
     */
    private static FileInputStream fis = null;


    public static void copyImge(String img, String copyimg) {
        try {
            fos = new FileOutputStream(copyimg);//复制文件
            fis = new FileInputStream(img);//源文件
            byte[] buf = new byte[1024];//缓冲区
            int len = 0;
            while ((len = fis.read(buf)) != -1) {
                fos.write(buf, 0, len);//复制
            }


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (fis != null)
                    fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (fos != null)
                    fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        copyImge("G:/image/copy/1.jpg", "G:/image/copy/1.png");//调用复制方法
    }
}

